#include <iostream>
#include <fstream>
#include <vector>
#include <chrono>


using namespace std;


vector<int> sort(vector<int>& w) {
   bool s = false;
   for (int i = w.size(); i > 0; --i) {
       s = false;
       for (int j = 0; j < i - 1; ++j) {
           if (w[j] > w[j + 1]) {
               int t = w[j];
               w[j] = w[j + 1];
               w[j + 1] = t;
               s = true;
           }
       }
       if (!s) {
           return w;
       }
   }


   return w;
}


int main() {
   ifstream file1("m1_sorted.txt");
   ifstream file2("m2_reverse.txt");
   ifstream file3("m3_shuffle.txt");


   vector<int> a, b, c;
   int num;


   while (file1 >> num) {
       a.push_back(num);
   }
   while (file2 >> num) {
       b.push_back(num);
   }
   while (file3 >> num) {
       c.push_back(num);
   }


   auto start = chrono::high_resolution_clock::now();
   sort(a);
   auto end = chrono::high_resolution_clock::now();
   auto duration = chrono::duration_cast<chrono::milliseconds>(end - start).count();
   cout << "m1_sorted " << duration << " milliseconds" << endl;


   start = chrono::high_resolution_clock::now();
   sort(b);
   end = chrono::high_resolution_clock::now();
   duration = chrono::duration_cast<chrono::milliseconds>(end - start).count();
   cout << "m2_reverse " << duration << " milliseconds" << endl;


   start = chrono::high_resolution_clock::now();
   sort(c);
   end = chrono::high_resolution_clock::now();
   duration = chrono::duration_cast<chrono::milliseconds>(end - start).count();
   cout << "m3_shuffle " << duration << " milliseconds" << endl;


   return 0;
}

